<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>栏目列表</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="<%=basePath%>libs/js/jquery.js"></script>
	<script type="text/javascript" src="<%=basePath%>libs/js/framework.js"></script>
	<link href="<%=basePath%>libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" id="skin" prePath="<%=basePath%>"/>
	<link rel="stylesheet" type="text/css" id="customSkin"/>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>dojo15/dijit/themes/tundra/tundra.css"/>
    <script type="text/javascript" src="<%=basePath%>dojo15/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
    <!--修正IE6支持透明png图片start-->
	<script type="text/javascript" src="<%=basePath%>js/method/pngFix/supersleight.js"></script>
	<!--修正IE6支持透明png图片end-->
    <script type="text/javascript">
	    dojo.require("dojo.data.ItemFileReadStore");
	    dojo.require("dijit.Tree");
	    dojo.require("dijit.Menu");
    </script>	
    <!--弹窗函数start-->
	<script>
		$(function(){
			top.Dialog.close()
		})
		function openWin(){
			var diag = new top.Dialog();
			diag.Title = "添加导航栏目";
			diag.URL = "Category_addPage.action";
			diag.Height=180;
			diag.show();
		}
		var globalid=null;
		function openModfiy(){
			var diag = new top.Dialog();
			diag.Title = "修改导航栏目";
			diag.URL = "Category_modifyPage.action?id="+globalid;
			diag.Height=180;
			diag.show();
		}
	</script>
	<!--弹窗函数end-->	
</head>

<body class=" tundra ">
<div>
	<div class="rbox_topcenter" style="margin-top:5px;">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<button onclick='openWin()'><span class="icon_page">创建栏目</span></button>
				</td>
			</tr>
		</table>
	</div>
	<br/>
	 <div id="scrollContent" style="padding:10px;text-align:left;"> 
	 <script>
	 	var globalid=null;
	 </script>
	<ul dojoType="dijit.Menu" id="tree_item_menu" style="display: none">
	    <li dojoType="dijit.MenuItem" onclick="openModfiy">修改</li>
	    <li dojoType="dijit.MenuItem" onclick='top.Dialog.confirm("确定要删除吗",function(){window.location="Category_delete.action?id="+globalid});'>删除</li>
	</ul>
	 	<div id="treeOne">
			<script type="text/javascript">
			   <s:property value="sbtree.toString()" escapeJavaScript="false" escapeHtml="false"/>
		   		function treeHandler(message) {        
			      var nodeWidget = message.node;
			      if (nodeWidget == null){return;}  
			      var nodeItem  = nodeWidget.item;
			      //window.parent.collapse.location.href="../"+nodeItem.link;
			      return true;
			      //other props 
			    }
		       function prepare() {
		    	   dojo.subscribe("treeOne", null, treeHandler); 
		    	   var openPopup = function(e){
						myClickedNode = dijit.getEnclosingWidget(e.target);
						globalid=myClickedNode.item.id;
					};
		            var store = new dojo.data.ItemFileReadStore({
		                data: {
		                    identifier: 'id',
		                    label: 'label',
		                    items: rawdata
		                }
		            });
		            var treeModel = new dijit.tree.ForestStoreModel({
		                store: store
		            });
		            var treeControl = new dijit.Tree({
		                model: treeModel,
		                showRoot: false,
		                _createTreeNode: function(
		                /*Object*/
		                args) {
		                    var tnode = new dijit._TreeNode(args);
		                    tnode.labelNode.innerHTML = args.label;
		                    return tnode;
		                }
		            },
		            "treeOne");
		            var pMenu=dijit.byId("tree_item_menu");
					pMenu.bindDomNode(dojo.byId("treeOne"));
					treeControl.myMenuHandle = dojo.connect(pMenu, "_openMyself", this,openPopup);
		        }
		
		        dojo.addOnLoad(prepare);
			</script>
		    <script type="text/javascript">
		        dojo.addOnLoad(function() {
		            if (document.pub) {
		                document.pub();
		            }
		        });
		    </script>	
		
		</div>
      </div>
</div>      
</body>
</html>

